#ifndef COMMON_H
#define COMMON_H


#include <stdint.h>
#include <error.h>
#include <errno.h>
#include <sys/queue.h>



#include "conf.h"

#define log(...) \
        error_at_line(0, errno, __func__, __LINE__, __VA_ARGS__)

#define info(...) error_at_line(0, 0, __func__, __LINE__, __VA_ARGS__)
extern void * alloc_block (size_t sz);
extern void * realloc_block (void *ptr, size_t sz);
extern void free_block(void *ptr);




extern void set_tcp_socket_keepalive_interval(int fd, int interval);
extern void set_tcp_socket_keepalive_count(int fd);
extern void set_tcp_socket_quickack(int fd);
extern void set_tcp_socket_nodelay(int fd);
extern void set_socket_nonblock(int fd);





#define aligned_by_size(_size) __attribute__ ((aligned (_size)))
#define aligned_by_cache_line(_size) aligned_by_size(CPU_CACHE_LINE_SIZE)

struct spinlock {
    pthread_spinlock_t lock;
} aligned_by_cache_line();




#endif
